/*
package com.iwop.moto.controller.web;

import com.iwop.moto.comm.Comm;
import com.iwop.moto.comm.ErrCode;
import com.iwop.moto.controller.BaseController;
import com.iwop.moto.model.ResultModel;
import com.iwop.moto.model.SuperRecordModel;
import com.iwop.moto.service.MTrademarkService;
import com.iwop.moto.utils.stringUtil.SequenceUtil;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;

*/
/**
 * Created by Administrator on 2016/9/9.
 *//*


@Controller
public class UpLoadFileController  extends BaseController{
    @Autowired
    MTrademarkService mTrademarkService;

    String GoodsMark="common/goodsmark/";
    String GOODS_LOGO="D:\\upload\\logo";
    String excel="D:\\upload\\品牌分类.xls";
    @RequestMapping("/api/file/upload")
    @ResponseBody
    public void motolist() {
        List<SuperRecordModel> trademarkList = mTrademarkService.getTrademarkList();
        File file=new File(GOODS_LOGO);
        File[] files = file.listFiles();
        for (File file1:files){
            String name = file1.getName();
            String dirUrl = getImageDateDir();
            try {
                InputStream inputStream=new FileInputStream(file1);
                File targetDir = new File(Comm.ROOT_PATH+GoodsMark+dirUrl);
                if(!targetDir.exists()){ targetDir.mkdirs();}
                String[] split = name.split("\\.");
                String serial = SequenceUtil.Serial()+"."+split[1];
                File targetFile = new File(Comm.ROOT_PATH+GoodsMark+dirUrl+serial);
                OutputStream outputStream=new FileOutputStream(targetFile);
                byte[] buffer = new byte[1024];
                int len = 0;
                while ((len = inputStream.read(buffer)) != -1) {
                    outputStream.write(buffer, 0, len);
                }
                inputStream.close();
                outputStream.close();
                SuperRecordModel superRecordModel = existData(trademarkList, split[0]);
                if(null !=superRecordModel){
                    superRecordModel.put("pictrue",Comm.WEB_FILEPATH+GoodsMark+dirUrl+serial);
                    mTrademarkService.upTrademark(superRecordModel);
                }
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    }

    public SuperRecordModel existData(List<SuperRecordModel> trademarkList,String name){
        SuperRecordModel SRModel=null;
        for (SuperRecordModel srm:trademarkList){
            if (srm.getString("name").equals(name)){
                SRModel=srm;
                continue;
            }
        }
        if(SRModel!=null){

        }
        return SRModel;
    }

    @RequestMapping("/api/file/excel")
    @ResponseBody
    public void readExcel(){
        try {
            File file=new File("D://word.xls");
            FileInputStream fileInputStream=new FileInputStream(file);
            File file1=new File("D://word1.xls");
            FileInputStream fileInputStream1=new FileInputStream(file1);
            readUserExcel1(fileInputStream, fileInputStream1);
        } catch (BiffException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public  void readUserExcel1(InputStream in,InputStream inputStream) throws BiffException, IOException {
        Workbook rwb = null;
        //获取Excel文件对象
        rwb = Workbook.getWorkbook(in);
        Workbook rwb1 = null;
        rwb1 = Workbook.getWorkbook(inputStream);
        //获取文件的指定工作表 默认的第一个
        Sheet sheet = rwb.getSheet(0);
        Sheet sheet1 = rwb1.getSheet(0);
        for(int i=0; i<sheet.getRows(); i++){
            boolean flag=true;
            String name = sheet.getCell(1, i).getContents()==null?"":sheet.getCell(1, i).getContents();
            for(int j=0; i<sheet1.getRows(); i++){
                String name1 = sheet1.getCell(1, i).getContents()==null?"":sheet1.getCell(1, i).getContents();
                if(name.equals(name1)){
                    flag=false;
                }
            }
            if(flag){
                System.out.println(name);
            }
        }
    }

    public  void readUserExcel(InputStream in) throws BiffException, IOException {
        //创建一个list 用来存储读取的内容
        Workbook rwb = null;
        Cell cell = null;
        //获取Excel文件对象
        rwb = Workbook.getWorkbook(in);
        StringBuffer sb=new StringBuffer();
        //获取文件的指定工作表 默认的第一个
        Sheet sheet = rwb.getSheet(0);
        //行数(表头的目录不需要，从1开始)
        for(int i=1; i<sheet.getRows(); i++){
            //创建一个数组 用来存储每一列的值
            String name = sheet.getCell(0, i).getContents()==null?"":sheet.getCell(0, i).getContents();
            SuperRecordModel srm=new SuperRecordModel();
            srm.put("tid",UUID.randomUUID().toString());
            srm.put("name",name);
            srm.put("status_flag","1");
            srm.put("sort",""+i);
            srm.put("status_time",new Date());
            mTrademarkService.insertTrademark(srm);
        }
    }

    public void main(String[] args) throws IOException, BiffException {
        File file=new File("D://word.xls");
        FileInputStream fileInputStream=new FileInputStream(file);
        File file1=new File("D://word1.xls");
        FileInputStream fileInputStream1=new FileInputStream(file1);
        readUserExcel1(fileInputStream, fileInputStream1);

    }

    */
/**
     * 创建日期路径
     * *//*

    public static String getImageDateDir() {
        SimpleDateFormat formatter=new SimpleDateFormat("yyyy/MM/dd");
        Date date=new Date();
        String datePath = formatter.format(date);
        //return "upload/images/" +datePath + "/";
        return datePath + "/";
    }

}
*/
